Skip to content

Fix editor saves on internal Playground origin#2102

Merged
chubes4 merged 2 commits into
mainfrom
fix/2095-editor-save-cors
Jul 26, 2026
Merged

Fix editor saves on internal Playground origin#2102
chubes4 merged 2 commits into
mainfrom
fix/2095-editor-save-cors

Conversation

@chubes4

@chubes4 chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Run authenticated editor browser commands on the direct local WordPress Playground origin so Gutenberg and its REST graph stay same-origin without entering the serialized preview proxy queue. Keep the proxy unchanged for exposed preview and reviewer URLs.

What changed

  • Preserve the upstream WordPress URL separately when wrapping a Playground server with the preview proxy.
  • Force wordpress.editor-open, wordpress.editor-actions, and wordpress.editor-validate-blocks internal sessions onto that local WordPress origin.
  • Remove the superseded response/header origin rewriting and mocked REST-preflight assertions.
  • Make browser-evaluated editor mutation/state/save logic source-launcher-safe by avoiding named closures that tsx rewrites with unavailable helpers.
  • Add the bounded real-runtime gate npm run test:editor-actions-save-integration.

Verification

  • npm run test:editor-actions-save-integration: passed against real WordPress Playground 6.5 in 13.0s. It creates a page, runs updateBlockAttributes, savePost, reload, and inspectState, then compares the post-reload editor SHA-256 with live get_post_field('post_content') SHA-256.
  • node --import tsx tests/browser-callback-materialization-contracts.test.ts: passed; proxy FIFO serialization and the separate WordPress origin contract remain covered.
  • node --import tsx tests/editor-actions.test.ts: passed.
  • npm run build: passed.

Compatibility and scope

No public command API changes. Proxy request serialization, preview routes, reviewer access, CORS policy, and network security are unchanged. The runtime change is limited to authenticated editor command sessions and generic editor browser-context serialization; there are no SSI or block-name special cases.

Evidence

  • Source relationship: closes Preview proxy blocks Gutenberg editor saves on CORS preflight #2095.
  • Change kind: runtime-origin routing correction plus real integration coverage.
  • Verification capability: real Playground editor mutation/save/reload persistence, not mocked proxy contracts.
  • Scope rationale: the direct origin already exists inside the Playground server; this change carries it alongside the externally exposed proxy URL and consumes it only for editor commands.

AI assistance

  • AI assistance: Yes
  • Tool(s): Homeboy (OpenCode)
  • Model: openai/gpt-5.6-sol
  • Used for: traced runtime-origin behavior, implemented and verified the bounded repair, and updated PR evidence.

@chubes4

chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Real end-to-end gate is currently failing, so this PR is draft.

The focused proxy contract passes, but the actual SSI recipe using this branch's source launcher timed out twice at wordpress.editor-actions after 25 minutes.

The command timeline identifies the regression:

  • Front-page editor open completes normally.
  • Contact editor open starts at 17:53:46 and does not settle before the outer timeout at 18:15:04.
  • Rewriting REST roots to the proxy sends Gutenberg preload/API traffic into the proxy's intentionally serialized one-request queue.
  • The editor never reaches the mutation/save sequence, so this does not fix #2095 end to end.

Required before ready:

  • Preserve same-origin editor REST behavior without routing the editor's REST preload graph through the serialized preview proxy.
  • Add a bounded real wordpress.editor-actions integration gate that opens an existing page, mutates a block, saves, reloads, and verifies the persisted content identity.
  • Rerun the original typed Description List proof successfully.

@chubes4
chubes4 marked this pull request as draft July 26, 2026 18:15
@chubes4 chubes4 changed the title Fix Gutenberg editor saves through preview proxy Fix editor saves on internal Playground origin Jul 26, 2026
@chubes4
chubes4 force-pushed the fix/2095-editor-save-cors branch from d57e303 to 96eb20d Compare July 26, 2026 19:07
@chubes4

chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Full downstream Gutenberg proof passed against rebased commit 96eb20d3565ab191588eb8a464c223c436f9a12a using SSI #729 and released Blocks Engine PHP transformer 0.4.8.

Evidence from WP Codebox recipe run run_1a0fb91b0bc14d989faaff472ef5c297:

  • terminal recipe status: succeeded; artifact bundle SHA-256 c7a4e8df7eb7104e019b17fba58c8d33b8c309e1e8831c0d31639fcdf62c2597
  • all eight university fixture editor surfaces opened successfully
  • typed blocks-engine/description-list attributes changed and serialized content became dirty
  • core/editor.savePost completed in 2,667 ms with marker Public lobby hours present
  • editor reload and post-reload state inspection succeeded; the marker remained in blocks-engine/description-list
  • editor validity: clean, 0 warnings, 0 command errors
  • post-save wp.blocks.validateBlock: 150/150 valid, 0 invalid, including four Description List blocks

Repo-native regression command: npm run test:editor-actions-save-integration. The full downstream matrix is generated through SSI bench/static-site-fixture-matrix.bench.mjs; the relevant browser sequence is wordpress.editor-actions (updateBlockAttributes, savePost, reload, inspectState) followed by wordpress.editor-validate-blocks.

@chubes4
chubes4 marked this pull request as ready for review July 26, 2026 19:09
@chubes4
chubes4 merged commit a742eca into main Jul 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview proxy blocks Gutenberg editor saves on CORS preflight

1 participant